#include <iostream>
#include <vector>
#include <math.h>

using namespace std;

int main()
{
    int n = 0;
    cin >> n;
    vector<int> arr(n), dp(n, 1);

    cin >> arr[0];

    int maxCount = 0;
    for (int i = 1; i < n; ++i)
    {
        cin >> arr[i];
        if (abs(arr[i] - arr[i - 1]) <= 1)
        {
            dp[i] += dp[i - 1];
            maxCount = max(maxCount, dp[i]);
        }
    }
    cout << maxCount << endl;
    return 0;
}